﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Framework;

namespace Enterprise.Admin.Handle.Order
{
    public partial class GetListJson : AdminBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            var datas = new List<object>();
            var pageValue = Fq("page").SafeToInt();
            var rowsValue = Fq("rows").SafeToInt();

            if (pageValue < 1)
            {
                pageValue = 1;
            }
            if (rowsValue < 1)
            {
                rowsValue = 10;
            }
            var orderService = new OrderService();
            var table = orderService.GetTable(pageValue, rowsValue);
            object result = new { total = table.Total, rows = datas };
            for (int i = 0; i < table.Rows.Count; i++)
            {
                datas.Add(new
                {
                    id = table.Rows[i]["CoOrderId"].SafeToInt(),
                    CoCode = table.Rows[i]["CoCode"].SafeToString(),
                    CoBuyerName = table.Rows[i]["CoBuyerName"].SafeToString(),
                    CoMobile = table.Rows[i]["CoMobile"].SafeToString(),
                    CoTelePhone = table.Rows[i]["CoTelePhone"].SafeToString(),
                    CoTotalAmount = table.Rows[i]["CoTotalAmount"].SafeToString(),
                    CoDate = table.Rows[i]["CoDate"].SafeToDateTime().ToString("yyyy-MM-dd HH:mm:ss"),
                });
            }
            Json(result);
        }
    }
}